<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.util.*" import="com.happypets.model.PageBean" import="com.happypets.model.PetBean"  import="com.happypets.model.UserBean"%>
<%
	String path = request.getContextPath() + "/web";
	session.removeAttribute("dogsFlag");
%>
<!DOCTYPE html>
<html>
<head>
<title>Happy Pets</title>
<link href="css/bootstrap.css" rel="stylesheet" type="text/css" media="all" />
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="js/utils.js"></script>
<script src="js/bootstrap.min.js"></script>
<!-- Custom Theme files -->
<!--theme-style-->
<link href="css/style.css" rel="stylesheet" type="text/css" media="all" />	
<!--//theme-style-->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="Feng design" />
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
<!--fonts-->
<!-- <link href='http://fonts.useso.com/css?family=Alegreya+Sans+SC:100,300,400,500,700,800,900,100italic,300italic,400italic,500italic,700italic,800italic,900italic' rel='stylesheet' type='text/css'>
<link href='http://fonts.useso.com/css?family=Lato:100,300,400,700,900,100italic,300italic,400italic,700italic,900italic' rel='stylesheet' type='text/css'> -->
<!--//fonts-->
<script type="text/javascript" src="js/move-top.js"></script>
<script type="text/javascript" src="js/easing.js"></script>
<script type="text/javascript" src="js/my.js"></script>
<script type="text/javascript" src="js/cart.js"></script>
<script type="text/javascript" src="js/myModal.js"></script>
<script type="text/javascript" src="js/search.js"></script>

<script type="text/javascript">
					jQuery(document).ready(function($) {
						$(".scroll").click(function(event){		
							event.preventDefault();
							$('html,body').animate({scrollTop:$(this.hash).offset().top},1000);
						});
					});
				</script>	
<!-- start menu -->
<script src="js/simpleCart.min.js"> </script>
<link href="css/memenu.css" rel="stylesheet" type="text/css" media="all" />
<script type="text/javascript" src="js/memenu.js"></script>
	<!-- 分页使用 -->
	<script type="text/javascript" src="js/bootstrap-paginator.js"></script>
<script>$(document).ready(function(){$(".memenu").memenu();});</script>
</head>
<body> 

	<%
	String t1 = (String)session.getAttribute("shape");
	String t2 = (String)session.getAttribute("color");
	String t3 = (String)session.getAttribute("category");
	String t4 = (String)session.getAttribute("keywords");
	
	boolean isSearch = false;
	if(t1 != null||t2 != null||t3 != null){
		isSearch = true;
	}
	
	%>

		<!-- 复制头部部分 -->
	<!--top-header-->
	<div class="top-header">
		<div class="container">
			<div class="top-header-main">
				<div class="col-md-4 top-header-left">
					<div class="search-bar">
						<!-- --------search-----no---- -->
						<input type="text" id="keyword" value="搜索"
							onfocus="this.value = '';"
							onblur="if (this.value == '') {this.value = '搜索';}"> <input
							type="submit" value="" id="search-btn">
						<!-- --------end------------ -->
					</div>
				</div>
				<div class="col-md-4 top-header-middle">
					<a href="index.jsp"><img src="../images/logo.png" alt="" /></a>
				</div>
				<div class="col-md-4 top-header-right">
					<div class="cart box_1">


						<!-- --------------------------------------购物车与登录部分----------------------no--------------------------- -->
						<p>
						
						<%
							UserBean user = (UserBean)session.getAttribute("user");
							String userId = "0";
							if(user == null){
								
								%>
								<span id="login_in" class=" btn-lg" data-toggle="modal"
								data-target="#loginModal">登录</span>/ <span id="regist"
								class=" btn-lg" data-toggle="modal" data-target="#registModal">注册</span>
								<span>
								<%}else{
									%>
										<a href="userInfo.jsp"class="btn"><span>
											<%=user.getUserName() %>
										</span></a><span class=" btn" id="exit-btn">退出</span>
									<%
									userId = user.getUserId();
								}
						
						%>
							<a href="checkout.jsp">
									<h3>
										<div class="total">

											<span class="simpleCart_total"></span> (<span
												id="simpleCart_quantity" class="simpleCart_quantity"></span>
											爱宠)

										</div>
									</h3> <img src="../images/cart-1.png" alt="" />
							</a></span>
						</p>


						<p>
							<a href="javascript:;" class="simpleCart_empty">空购物车</a>
						</p>

						<script type="text/javascript">
						//初始化购物车
						cart_add(1,1,3,<%=userId%>,0);
						</script>

						<!-- ----------------------------------------------------end----------------------------------------------------->

						<div class="clearfix"></div>
					</div>
				</div>
				<div class="clearfix"></div>
			</div>
		</div>
	</div>
	<!--top-header-->
	<!--bottom-header-->
	<div class="header-bottom">
		<div class="container">
			<div class="top-nav">
				<ul class="memenu skyblue">
					<li class="active"><a href="index.jsp">主页</a></li>
					<li class="grid"><a href="dogs.jsp?kind=1">狗狗</a>
						<div class="mepanel">
							<div class="row">
								<div class="col1 me-one">
									<h4>大型犬</h4>
									<ul>
										<!--从数据库中读取前8条狗类图片-->
										<!-- 直接读取耗时，为了能修改还是建议从数据库中读取 -->
										<!-- 再次思考认为直接写死，后台修改 -->
										<!--  页面跳转到servlet-->
										<li><a href="products.html">藏獒</a></li>
										<li><a href="products.html">卡斯罗</a></li>
										<li><a href="products.html">罗威纳犬</a></li>
										<li><a href="products.html">阿拉斯加雪橇犬</a></li>
										<li><a href="products.html">法老王猎犬</a></li>
										<li><a href="dogs.jsp?kind=1">更多</a></li>
									</ul>
								</div>
								<div class="col1 me-one">
									<h4>中型犬</h4>
									<ul>
										<li><a href="products.html">斑点狗</a></li>
										<li><a href="products.html">杜宾犬</a></li>
										<li><a href="products.html">哈士奇</a></li>
										<li><a href="products.html">灵缇</a></li>
										<li><a href="dogs.jsp?kind=1.jsp">更多</a></li>
									</ul>
								</div>
								<div class="col1 me-one">
									<h4>小型犬</h4>
									<ul>
										<li><a href="products.html">吉娃娃</a></li>
										<li><a href="products.html">蝴蝶犬</a></li>
										<li><a href="products.html">北京犬</a></li>
										<li><a href="products.html">苏格兰梗</a></li>
										<li><a href="products.html">比格猎犬</a></li>
										<li><a href="products.html">拉萨犬</a></li>
										<li><a href="dogs.jsp">更多</a></li>
									</ul>
								</div>
							</div>
						</div></li>
					<li class="grid"><a href="dogs.jsp?kind=2">猫咪</a>
						<div class="mepanel">
							<div class="row">
								<div class="col1 me-one">
									<h4>长毛猫</h4>
									<ul>
										<li><a href="products.html">波斯猫</a></li>
										<li><a href="products.html">布偶猫</a></li>
										<li><a href="products.html">伯曼猫</a></li>
										<li><a href="products.html">索马里猫</a></li>
										<li><a href="products.html">巴厘猫</a></li>
										<li><a href="dogs.jsp?kind=2">更多</a></li>
									</ul>
								</div>
								<div class="col1 me-one">
									<h4>短毛猫</h4>
									<ul>
										<li><a href="products.html">中国狸花猫</a></li>
										<li><a href="products.html">埃及猫</a></li>
										<li><a href="products.html">俄罗斯蓝猫</a></li>
										<li><a href="products.html">孟买猫</a></li>
										<li><a href="dogs.jsp?kind=2">更多</a></li>
									</ul>
								</div>
								<div class="col1 me-one">
									<h4>无毛猫</h4>
									<ul>
										<li><a href="products.html">斯芬克斯猫</a></li>
										<li><a href="products.html">加拿大无毛猫</a></li>
										<li><a href="dogs.jsp?kind=2">更多</a></li>
									</ul>
								</div>
							</div>
						</div></li>
					<li class="grid"><a href="single.html">鸟类</a>
						<div class="mepanel">
							<div class="row">
								<div class="col1 me-one">
									<h4>鸣禽</h4>
									<ul>
										<li><a href="products.html">New Arrivals</a></li>
										<li><a href="products.html">Men</a></li>
										<li><a href="products.html">Women</a></li>
										<li><a href="products.html">Accessories</a></li>
										<li><a href="products.html">Kids</a></li>
										<li><a href="products.html">login</a></li>
										<li><a href="products.html">Brands</a></li>
										<li><a href="products.html">更多</a></li>
									</ul>
								</div>
								<div class="col1 me-one">
									<h4>宠物鸟</h4>
									<ul>
										<li><a href="products.html">Men</a></li>
										<li><a href="products.html">Women</a></li>
										<li><a href="products.html">Brands</a></li>
										<li><a href="products.html">Kids</a></li>
										<li><a href="products.html">Accessories</a></li>
										<li><a href="products.html">更多</a></li>
									</ul>
								</div>
								<div class="col1 me-one">
									<h4>观赏鸟</h4>
									<ul>
										<li><a href="products.html">Levis</a></li>
										<li><a href="products.html">Persol</a></li>
										<li><a href="products.html">Nike</a></li>
										<li><a href="products.html">Edwin</a></li>
										<li><a href="products.html">New Balance</a></li>
										<li><a href="products.html">Jack & Jones</a></li>
										<li><a href="products.html">Paul Smith</a></li>
										<li><a href="products.html">Ray-Ban</a></li>
										<li><a href="products.html">更多</a></li>
									</ul>
								</div>
							</div>
						</div></li>
					<li class="grid"><a href="dogs.html">其它</a>
						<div class="mepanel">
							<div class="row">
								<div class="col1 me-one">
									<h4>昆虫</h4>
									<ul>
										<li><a href="products.html">蜘蛛</a></li>
										<li><a href="products.html">螳螂</a></li>
										<li><a href="products.html">蝎子</a></li>
										<li><a href="products.html">蜗牛</a></li>
										<li><a href="products.html">蚯蚓</a></li>
										<li><a href="products.html">蜥蜴</a></li>
										<li><a href="products.html">龙虾</a></li>
										<li><a href="products.html">更多</a></li>
									</ul>
								</div>
								<div class="col1 me-one">
									<h4>鱼类</h4>
									<ul>
										<li><a href="products.html">青鱼</a></li>
										<li><a href="products.html">草鱼</a></li>
										<li><a href="products.html">金鱼</a></li>
										<li><a href="products.html">中华鲟</a></li>
										<li><a href="products.html">扬子鳄</a></li>
										<li><a href="products.html">更多</a></li>
									</ul>
								</div>
								<div class="col1 me-one">
									<h4>奇葩宠物</h4>
									<ul>
										<li><a href="products.html">蟒蛇</a></li>
										<li><a href="products.html">剑齿虎</a></li>
										<li><a href="products.html">长颈鹿</a></li>
										<li><a href="products.html">狮子</a></li>
										<li><a href="products.html">蓝鲸</a></li>
										<li><a href="products.html">企稳</a></li>
										<li><a href="products.html">普氏野马</a></li>
										<li><a href="products.html">黑曼巴</a></li>
										<li><a href="products.html">更多</a></li>
									</ul>
								</div>
							</div>
						</div></li>
				</ul>
			</div>
			<div class="clearfix"></div>
		</div>
	</div>
	<!--bottom-header-->
	<!-- 复制部分结束 -->

	<!--start-breadcrumbs-->
	<div class="breadcrumbs">
		<div class="container">
			<div class="breadcrumbs-main">
				<ol class="breadcrumb">
					<li><a href="index.jsp">主页</a></li>
					<li class="active">汪星人</li>
				</ol>
			</div>
		</div>
	</div>
	<!--end-breadcrumbs-->
	
			<!-- 先判断是否有错误 -->
				<%
					PageBean pages = (PageBean)session.getAttribute("pageBean");
					List<PetBean> pets = (List<PetBean>)session.getAttribute("pets");
					
					if(pages==null||pets.size()<=0||pets==null){
						%>
						<h1 align="center"> 抱歉，暂无数据！</h1>
						<%
					}else{
										
					int currentPageNumber = pages.getCurrentPageNumber();
					int allNumber = pages.getAllNumber();
					int maxPageNumber = pages.getMaxPageNumber();
					int pageShowNumber = pages.getShowNumber();
						
						
				%>
	
	<!--start-product--> 
	<div class="product">
		<div class="container">
			<div class="product-main">
				<div class="col-md-9 p-left">
				<div class="product-one">
				
				
				
				
				
				<!-- 单独宠物，数据库实现 -->
				<%
				
				for(int i=0;i<pets.size();i++){
					PetBean pet = pets.get(i);
				
				%>
				
				<div class="col-md-4 product-left single-left"> 
					<div class="p-one simpleCart_shelfItem">
						<a href="dog.jsp?id=<%=pet.getId() %>">
								<img src="../images/<%=pet.getImage1() %>" alt="" width="200px"height="150px"/>
								<div class="mask mask1">
									<span>快速查看</span>
								</div>
							</a>
						<h4><%=pet.getName() %></h4>
						<p>
							<!-- 宠物id，数量，标志，用户id，价格 -->
							<a class="item_add" href="#"
								onclick="cart_add(<%=pet.getId()%>,1,1,<%=userId %>,<%=pet.getSpecialPrice()%>)"><span
								style="display: none"><%=pet.getId()%></span><i></i> <span
								class=" item_price">￥<%=pet.getNowPrice()%></span></a>
						</p>
					</div>
				</div>
				
				<% 
				if(i%3==2){
					%>
					<div class="clearfix"> </div>
					<%
				}
				
				
				} %>
				
			<div class="clearfix"> </div>
			</div>
			

				<br>
				<br>
				<br>
				
							
				<div style="margin-left:auto;margin-right:auto;text-align:center" class="page-show">
				<span class="b-btn" onclick="lastPage(<%=currentPageNumber%>,<%=isSearch%>)">
				<a> 上一页 </a>
				</span>&nbsp;
				
				<%
				int temp = 3;
				if(maxPageNumber < 3){
					temp = maxPageNumber;
				}
				
				for(int i=1;i<=temp;i++){
					%>
				<span class="b-btn">				<!-- 当前页数，跳转页数，是否搜索 -->
				<a href="#" onclick="pageForward(<%=currentPageNumber%>,<%=i%>,<%=isSearch%>)"> <%=i %> </a>
				</span>&nbsp;
					<%
				}
				%>

				...
				<span class="b-btn" onclick="nextPage(<%=currentPageNumber%>,<%=maxPageNumber%>,<%=isSearch%>)">
				<a> 下一页 </a>
				</span>
				<span style="font-size:19">现在是第<%=currentPageNumber %>页，共<%=maxPageNumber %>页，到第
				<input type="number"  id="selectPage"  value="<%=currentPageNumber %>" maxlength="3" style="height:30px;width:50px" />
				页<span class="b-btn" onclick="pageSure(<%=maxPageNumber%>,<%=isSearch%>)"><a> 确 定 </a></span>
				</span>
				</div>
			
			</div>
			
			
			<div class="col-md-3 p-right single-right">
				<!-- 直接从数据库里读取，动态生成 -->
				<!-- 品种 -->
				<h3>品种</h3>
					<ul class="product-categories">
						<%
							List<Map<String,String>> category = (List<Map<String,String>>)session.getAttribute("categories");
							
							
							for(int i = 0;i<category.size();i++){
								Map<String,String> map = category.get(i);
								%>
								<li><a href="dogs.jsp?category=<%=map.get("NAME")%>"><%=map.get("NAME") %></a> <span class="count">(<%=map.get("COUNT(*)") %>)</span></li>
								<%
							}
							
							
						%>
					</ul>
					<h3>颜色</h3>
					<ul class="product-categories">
					
					
						<%
							List<Map<String,String>> color = (List<Map<String,String>>)session.getAttribute("colors");
							
							
							for(int i = 0;i<color.size();i++){
								Map<String,String> map = color.get(i);
								%>
								<li><a href="dogs.jsp?color=<%=map.get("ANIMAL_COLOR")%>"><%=map.get("ANIMAL_COLOR") %></a> <span class="count">(<%=map.get("COUNT(*)") %>)</span></li>
								<%
							}
						%>
					</ul>
					<h3>体型</h3>
					<ul class="product-categories">
					
						<%
							List<Map<String,String>> shape = (List<Map<String,String>>)session.getAttribute("shapes");
							
							
							for(int i = 0;i<shape.size();i++){
								Map<String,String> map = shape.get(i);
								%>
								<li><a href="dogs.jsp?shape=<%=map.get("ANIMAL_SHAPE") %>"><%=map.get("ANIMAL_SHAPE") %></a> <span class="count">(<%=map.get("COUNT(*)") %>)</span></li>
								<%
							}
						%>
					</ul>
			</div>
			<div class="clearfix"> </div>
		</div>
	</div>
	</div>
	<!--end-product-->
	<%} %>

	<!-- 复制尾部部分 -->

	<!--start-footer-->
	<div class="footer">
		<div class="container">
			<div class="footer-top">
				<div class="col-md-3 footer-left">
					<h3>关于我们</h3>
					<ul>
						<li><a href="#">了解我们</a></li>
						<li><a href="contact.html">意见建议</a></li>
						<li><a href="#">博客</a></li>
						<li><a href="#">团队</a></li>					 
					</ul>
				</div>
				<div class="col-md-3 footer-left">
					<h3>帐户</h3>
					<ul>
						<li><a href="account.html">您的帐户</a></li>
						<li><a href="#">个人信息</a></li>
						<li><a href="contact.html">收货地址</a></li>
						<li><a href="#">快递追踪</a></li>					 					 
					</ul>
				</div>
				<div class="col-md-3 footer-left">
					<h3>购物指南</h3>
					<ul>
						<li><a href="#">订单查询</a></li>
						<li><a href="#">配送费收取标准</a></li>
						<li><a href="#">在线自助退货</a></li>
						<li><a href="#">帮助</a></li>					 
					</ul>
				</div>
				<div class="col-md-3 footer-left">
					<h3>爱宠种类</h3>
					<ul>
						<li><a href="#">狗狗</a></li>
						<li><a href="#">猫咪</a></li>
						<li><a href="#">小鸟</a></li>
						<li><a href="#">鱼类</a></li>
						<li><a href="#">其它</a></li>				 
					</ul>
				</div>
				<div class="clearfix"> </div>
			</div>
		</div>
	</div>
	<!--end-footer-->
	<!--end-footer-text-->
	<div class="footer-text">
		<div class="container">
			<div class="footer-main">
				<p class="footer-class">© 2015 Free Style All Rights Reserved | Design by  <a href="http://feng.sinaapp.com/" target="_blank">FENG</a> </p>
			</div>
		</div>
		<script type="text/javascript">
									$(document).ready(function() {
										/*
										var defaults = {
								  			containerID: 'toTop', // fading element id
											containerHoverID: 'toTopHover', // fading element hover id
											scrollSpeed: 1200,
											easingType: 'linear' 
								 		};
										*/
										
										$().UItoTop({ easingType: 'easeOutQuart' });
										
									});
								</script>
								
								getUserId(<%=userId %>);
								
		<a href="#home" id="toTop" class="scroll" style="display: block;"> <span id="toTopHover" style="opacity: 1;"> </span></a>
	</div>
	<div id="userId" style="display:none"><%=userId %></div>
	<!--end-footer-text-->	
	<!-- 尾部结束 -->

<jsp:include page="modal.html"></jsp:include>
</body>
</html>